import { createContext } from 'react';
import defaultState from './state';

export const Context = createContext({}); //创建Context，管理共享数据

export const reducer = (state = defaultState, action) => {
  ///reducer负责操作数据
  if (action.type === 'add') {
    const obj = { ...state, total: state.total + 1 };
    window.defaultState = obj;
    return window.defaultState;
  }
  return state;
};
